package main.iwith;

import main.util.StringUtil;

import java.io.*;

public class ToItemFile {

	public static void main(String[] args) throws Exception {
		FileReader file=null;
		OutputStreamWriter osw=null;
		try {
			file = new FileReader("G:/180和183店铺.txt");
			
			FileOutputStream fos=new FileOutputStream("G:/新增菜名20180827.dict");
			osw=new OutputStreamWriter(fos,"utf-8");
			
			BufferedReader br=new BufferedReader(file);
	        String line ;
	        
	        fos.write(new byte[]{(byte)0xEF, (byte)0xBB, (byte)0xBF});
	        while ((line = br.readLine())!=null){
	        	if(StringUtil.isEmpty(line.trim())){
	        		continue;
	        	}
	        	
	        	osw.write(getDictLine(line.trim()));
	        }
	        
	        osw.flush();
	        osw.close();
			fos.close();
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			file.close();
			//osw.close();
		}
	}
	
	public static String getDictLine(String name) throws UnsupportedEncodingException{
		StringBuffer sb=new StringBuffer();
		sb.append("name:");
		sb.append(name);
		sb.append("\t");
		sb.append("type:菜名\tentity:1\tentityclass:/菜名\talias:");
		sb.append("\n");
		System.out.println(sb.toString());
		return sb.toString();
	}
}
